home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Sample Code / Overview / DTS.Utilities / Utilities.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  23.1 KB  |  539 lines  |  [TEXT/MPS ]

  1. /*-----------------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    Collection of Utilities for DTS Sample code
  6. #
  7. #    Program:    Utilities.c.o
  8. #    File:        Utilities.h    -    Header for C Source
  9. #
  10. #    Copyright © 1988-1990 Apple Computer, Inc.
  11. #    All rights reserved.
  12. #
  13. -----------------------------------------------------------------------------------------*/
  14.  
  15. #ifndef __UTILITIES__
  16. #define __UTILITIES__
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21.  
  22. #ifndef __QUICKDRAW__
  23. #include <QuickDraw.h>
  24. #endif
  25.  
  26. #ifndef __DIALOGS__
  27. #include <Dialogs.h>
  28. #endif
  29.  
  30. #ifndef __FILES__
  31. #include <Files.h>
  32. #endif
  33.  
  34. #ifndef __MEMORY__
  35. #include <Memory.h>
  36. #endif
  37.  
  38. #ifndef __OSUTILS__
  39. #include <OSUtils.h>
  40. #endif
  41.  
  42. #ifndef __WINDOWS__
  43. #include <Windows.h>
  44. #endif
  45.  
  46. #ifndef __GESTALT__
  47. #include "Gestalt.h"
  48. #endif
  49.  
  50. #ifndef __FOLDERS__
  51. #include <Folders.h>
  52. #endif
  53.  
  54. #include "UtilitiesCommon.h"
  55.  
  56. /*-----------------------------------------------------------------------------------------
  57.     Global constants
  58. -----------------------------------------------------------------------------------------*/
  59.  
  60. #define    kOSEvent                app4Evt        /* event used by MultiFinder */
  61. #define    kSuspendResumeMessage    1            /* high byte of suspend/resume event message */
  62. #define    kResumeMask                1            /* bit of message field for resume vs. suspend */
  63. #define    kMouseMovedMessage        0xFA        /* high byte of mouse-moved event message */
  64. #define    kNoEvents                0            /* no events mask */
  65.  
  66. #define kDelayTime                8            /* For the delay time when flashing the
  67.                                                menubar and highlighting a button.
  68.                                                8/60ths of a second*/
  69.  
  70. #define kStartPtH                2            /* offset from the left of the screen */
  71. #define kStartPtV                2            /* offset from the top of the screen */
  72. #define kStaggerH                12            /* staggering amounts for new windows */
  73. #define kStaggerV                16
  74.  
  75. #define chBackspace                '\b'        /* ASCII code for Backspace character */
  76. #define chClear                    '\033'        /* ASCII code for Clear key (aka ESC) */
  77. #define chDown                    '\037'        /* ASCII code for down arrow */
  78. #define chEnd                    '\004'        /* ASCII code for the End key */
  79. #define chEnter                    '\003'        /* ASCII code for Enter character */
  80. #define chEscape                '\033'        /* ASCII code for Escape (aka Clear) key */
  81. #define chFunction                '\020'        /* ASCII code for any function key */
  82. #define chFwdDelete                '\177'        /* ASCII code for forward delete */
  83. #define chHelp                    '\005'        /* ASCII code for Help key */
  84. #define chHome                    '\001'        /* ASCII code for the Home key */
  85. #define chLeft                    '\034'        /* ASCII code for left arrow */
  86. #define chPageDown                '\f'        /* ASCII code for Page Down key */
  87. #define chPageUp                '\013'        /* ASCII code for Page Up key */
  88. #define chReturn                '\n'        /* ASCII code for Return character */
  89. #define chRight                    '\035'        /* ASCII code for right arrow */
  90. #define chSpace                    ' '            /* ASCII code for Space character */
  91. #define chTab                    '\t'        /* ASCII code for Tab character */
  92. #define chUp                    '\036'        /* ASCII code for up arrow */
  93.  
  94. enum { kQDOriginal = 0, kQD8Bit, kQD32Bit };    /* For use with gQDVersion */
  95.  
  96. /*-----------------------------------------------------------------------------------------
  97.     Types
  98. -----------------------------------------------------------------------------------------*/
  99.  
  100. typedef short *IntegerPtr, **IntegerHandle;
  101.  
  102. typedef long *LongintPtr, **LongintHandle;
  103.  
  104. typedef Boolean *BooleanPtr, **BooleanHandle;
  105.  
  106. typedef Rect *RectPtr, **RectHandle;
  107.  
  108. struct    WindowTemplate    {                    /*template to a WIND resource*/
  109.     Rect    boundsRect;
  110.     short    procID;
  111.     Boolean    visible;
  112.     Boolean    filler1;
  113.     Boolean    goAwayFlag;
  114.     Boolean    filler2;
  115.     long    refCon;
  116.     Str255    title;
  117. };
  118. typedef    struct    WindowTemplate    WindowTemplate;
  119. typedef            WindowTemplate    *WindowTPtr, **WindowTHndl;
  120.  
  121. typedef Rect (*PositionWndProcPtr)(WindowPtr window, WindowPtr relatedWindow);
  122.  
  123. /*-----------------------------------------------------------------------------------------
  124.     Handy Macros/inlines
  125. -----------------------------------------------------------------------------------------*/
  126. #ifdef false                                        /* The c++ stuff is turned OFF!!! */
  127.  
  128. inline long abs(val) 
  129. {    return ((val < 0) ? (-val) : (val)); }            /* Absolute value */
  130.  
  131. inline void PStrCopy(dest, src)                        /* Pascal string copy */
  132. {    BlockMove (src, dest, (*(char *)(src))+1); }
  133.  
  134. inline Point* TopLeft(Rect& r)                        /* provide access to rect.topLeft  */
  135. {    return (Point*)(&r.top); }
  136.  
  137. inline Point* BotRight(Rect& r)                        /* provide access to rect.botRight  */
  138. {    return (Point*)(&r.bottom); }
  139.  
  140. inline void SETPT(Point *pt,short h,short v)
  141. {    (*pt).h = h; (*pt).v = v); }
  142.  
  143. inline void SETRECT(Rect *r,short left,short top,short right,short bottom)
  144. {    SETPT(TopLeft(*r), left, top); SETPT(BotRight(*r), right, bottom); }
  145.  
  146. /* 
  147.  *    Useful functions for testing gestalt attribute responses
  148.  *
  149.  *    BTstBool returns a true boolean value (0 or 1), but is slower than:
  150.  *    BTstQ which simply returns a non-zero value if the bit is set which
  151.  *    means the result could get lost if assigned to a short, for example.
  152.  *
  153.  *    arg is any integer value, bitnbr is the number of the bit to be tested.
  154.  *    bitnbr = 0 is the least significant bit.
  155.  */
  156. inline short BTstBool(arg, bitnbr)    
  157. {    return ((arg >> bitnbr) & 1); }
  158.  
  159. inline long BTstQ(arg, bitnbr)
  160. {    return (arg & (1 << bitnbr)); }
  161.  
  162. #else
  163.  
  164.  
  165. #ifndef THINK_C
  166. #define QD(whatever) (qd.##whatever)
  167. #else
  168. #define QD(whatever) (whatever)
  169. #endif
  170.  
  171.  
  172. /* define our own abs() so we don't need StdLib */
  173. #define abs(val) (((val) < 0) ? (-(val)) : (val))
  174. /* Pascal string copy */
  175. #define PStrCopy(dest, src)    (BlockMove (src, dest, (*(char *)(src))+1))
  176. #define TopLeft(r)        (* (Point *) &(r).top)
  177. #define BotRight(r)        (* (Point *) &(r).bottom)
  178. #define MIN(a, b) ((a) < (b) ? (a) : (b) )
  179. #define MAX(a, b) ((a) > (b) ? (a) : (b) )
  180. #define SETPT(pt, x, y)    (*(pt)).h = (x); (*(pt)).v = (y)
  181. #define SETRECT(r, left, top, right, bottom)    \
  182.                         SETPT(&TopLeft(*(r)), (left), (top)); \
  183.                         SETPT(&BotRight(*(r)), (right), (bottom))
  184. /* 
  185.  *    Useful macros for testing gestalt attribute responses
  186.  *
  187.  *    BTstBool returns a true boolean value (0 or 1), but is slower than:
  188.  *    BTstQ which simply returns a non-zero value if the bit is set which
  189.  *    means the result could get lost if assigned to a short, for example.
  190.  *
  191.  *    arg is any integer value, bitnbr is the number of the bit to be tested.
  192.  *    bitnbr = 0 is the least significant bit.
  193.  */
  194. #define BTstBool(arg, bitnbr)    ((arg >> bitnbr) & 1)
  195. #define BTstQ(arg, bitnbr)        (arg & (1 << bitnbr))
  196.  
  197. #endif
  198.  
  199. /*-----------------------------------------------------------------------------------------
  200.     Global variables
  201. -----------------------------------------------------------------------------------------*/
  202. /*    The following global variables are initialized by StardardInitialization to
  203.  *    define the environnment.  This used to be a single SysEnvRec, but now,
  204.  *    all those variables defined in a SysEnvRec can be returned by Gestalt
  205.  *    (except sysVRefNum; see FindSysFolder).  Note that all the variables
  206.  *    below will be correctly initialized whether Gestalt is available or not;
  207.  *    the Gestalt glue handles this.
  208.  */
  209. extern short            gMachineType;            /* which machine this is */
  210. extern short            gSystemVersion;            /* System version number */
  211. extern short            gProcessorType;            /* which CPU this is */
  212. extern Boolean            gHasFPU;                /* true if machine has an FPU */
  213. extern short            gQDVersion;                /* major QD version #; 0 for original, 
  214.                                                     1 for color QD, 2 for 32-bit QD */
  215. extern short            gKeyboardType;            /* which type of keyboard is present */
  216. extern short            gAppleTalkVersion;        /* AppleTalk version number */
  217.         
  218. /*    These are also handled by Gestalt. gHasPMMU has no corresponding SysEnvRec
  219.  *    field, but it is handled by the glue, so we include it here for completeness.
  220.  *    gAUXVersion will be initialized with Gestalt if present, but correctly
  221.  *    set even if Gestalt is not available
  222.  */
  223. extern Boolean            gHasPMMU;                /* true if machine has a PMMU or equivalent */
  224. extern short            gAUXVersion;            /* major A/UX version number (0 if not present) */
  225.  
  226. /*    
  227.  *    gHasWaitNextEvent is set to TRUE if the Macintosh we are running on has
  228.  *    WaitNextEvent implemented. We can use this in our main event loop to
  229.  *    determine whether to call WaitNextEvent or GetNextEvent.
  230.  */
  231. extern Boolean            gHasWaitNextEvent;
  232.  
  233. /*
  234.  *    gAppResRef is the application’s resource file reference. I need to save
  235.  *    this since I can open other resource files. The current resource file is
  236.  *    always gAppResRef unless I momentarily set it to another file to read its
  237.  *    resources, and then immediately restore it back.
  238.  */
  239. extern short            gAppResRef;
  240.  
  241. /*
  242.  *    gInBackground is maintained by our osEvent handling routines. Any part of
  243.  *    the program can check it to find out if it is currently in the background.
  244.  */
  245. extern Boolean            gInBackground;            /* maintained by StandardInitialization
  246.                                                       and DoEvent */
  247.                                                       
  248. /*
  249.  *    gAppName holds the name of the application that's running. You can use if
  250.  *    for any purpose you'd like. It is also used by StandardAbout if it can't
  251.  *    find a string to use for the application name in a resource, so make sure
  252.  *    you call InitForStandardAbout if you are going to call StandardAbout. If you
  253.  *    call StandardInitialization, this is done for you.
  254.  */
  255. extern Str255            gAppName;
  256.  
  257. /*
  258.  *    gSignature holds the creator signature for the running application. It follows the
  259.  *    same rules as those for gAppName.
  260.  */
  261. extern OSType            gSignature;
  262.  
  263. /*
  264.  *    Initial values of these global variables are set to zero or FALSE by MPW's 
  265.  *    runtime initialization routines.  If the Utilities initialization routines
  266.  *    have been properly called, then gUtilitiesInited will be true.  If it is
  267.  *    not true, then the values of the above global variables are invalid.
  268.  */
  269. extern Boolean            gUtilitiesInited;
  270.  
  271. /*-----------------------------------------------------------------------------------------
  272.     Interface to routines
  273. -----------------------------------------------------------------------------------------*/
  274.  
  275. #ifdef __cplusplus
  276. extern "C" {
  277. #endif
  278.  
  279. short        CenteredAlert(short alertID, WindowPtr relWindow);
  280.             /* Given an Alert ID and a related window pointer, this routine will center
  281.                the alert on the same device as the related window.  If the related
  282.                window pointer is NULL, then the alert will be centered on the device
  283.                that the alert would normally be placed if Alert was called directly. */
  284.  
  285. void        CenterRectInRect(Rect outerRect, Rect *innerRect);
  286.             /* Given two rectangles, this routine centers the second one within the first. */
  287.  
  288. Rect        CenterWindow(WindowPtr window, WindowPtr relatedWindow);
  289.             /* Given a window pointer and a related window pointer, this routine will
  290.                center the window on the same device as the related window.  If the
  291.                related window pointer is NULL, then the window will be centered on the
  292.                device that the window already is.
  293.                WARNING: This routine may move or purge memory. */
  294.  
  295. void        CloseAnyWindow(WindowPtr window);
  296.             /* Closes the indicated window.  Does the right thing, taking into account
  297.                that the window may belong to a DA.
  298.                WARNING: An application window is closed via a CloseWindow call.  Use
  299.                            this call when you want to keep the storage for the window
  300.                         record.  (Compare against DisposeAnyWindow.) */
  301.  
  302. void        DisposeAnyWindow(WindowPtr window);
  303.             /* Disposes of the indicated window.  Does the right thing, taking into account
  304.                that the window may belong to a DA.
  305.                WARNING: An application window is closed via a DisposeWindow call.  Use
  306.                            this call when you want to free up the storage for the window
  307.                         record.  (Compare against CloseAnyWindow.) */
  308.  
  309. void        DeathAlert(short errResID, short errStringIndex);
  310.             /* Display an alert that tells the user an error occurred, then exit the
  311.                program. This routine is used as an ultimate bail-out for serious errors
  312.                that prohibit the continuation of the application. */ 
  313.  
  314. void        DeathAlertMessage(short errResID, short errStringIndex, short message);
  315.  
  316. void        ErrorAlert(short errResID, short errStringIndex);
  317.  
  318. void        ErrorAlertMessage(short errResID, short errStringIndex, short message);
  319.  
  320. OSErr        FindSysFolder(short *foundVRefNum, long *foundDirID);
  321.             /* FindSysFolder returns the (real) vRefNum, and the DirID of the current
  322.                system folder.  It uses the Folder Manager if present, otherwise
  323.                it falls back to SysEnvirons.  It returns zero on success, otherwise
  324.                a standard system error. */
  325.  
  326. Handle        GetAppIndResource(ResType theType, short index, OSErr *err);
  327.             /* GetAppIndResource gets a resource from the application's res file by index */
  328.  
  329. Handle        GetAppNamedResource(ResType theType, Str255 name, OSErr *err);
  330.             /* GetAppNamedResource gets a resource from the application's res file by name */
  331.  
  332. Handle        GetAppResource(ResType theType, short theID, OSErr *err);
  333.             /* GetAppResource gets a resource from the application's res file by resource ID */
  334.  
  335. short        GetAUXVersion( void);
  336.             /* getAUXVersion -- Checks for the presence of A/UX by whatever means is
  337.                appropriate.  Returns the major version number of A/UX (i.e. 0 if A/UX 
  338.                is not present, 1 for any 1.x.x version 2 for any 2.x version, etc.
  339.                This code should work for all past, present and future A/UX systems. */
  340.  
  341. DialogPtr    GetCenteredDialog(short id, DialogPtr storage, WindowPtr relatedWindow, WindowPtr behind);
  342.             /* Given a dialog ID and a related window pointer, this routine will center
  343.                the dialog on the same device as the related window.  If the related
  344.                window pointer is NULL, then the dialog will be centered on the device
  345.                that the dialog would normally be placed if GetNewDialog was called. */
  346.  
  347. WindowPtr    GetCenteredWindow(short id, Ptr storage, WindowPtr relWindow, WindowPtr behind, Boolean inColor);
  348.             /* Given a window ID and a related window pointer, this routine will center
  349.                the window on the same device as the related window.  If the related
  350.                window pointer is NULL, then the window will be centered on the device
  351.                that the window would normally be placed if GetNewWindow was called. */
  352.  
  353. Boolean     GetCheckOrRadio(DialogPtr dlgPtr, short itemNo);
  354.  
  355. long        GetGestaltResult(OSType gestaltSelector);
  356.             /* GetGestaltResult returns the result value from Gestalt for the specified
  357.                selector.  If Gestalt returned an error GetGestaltResult returns zero.  Use 
  358.                of this function is only cool if we don't care whether Gestalt returned an 
  359.                error.  In many casesyou may need to know the exact Gestalt error code so 
  360.                then this routine would be inappropriate. */
  361.  
  362. Point        GetGlobalMouse(void);
  363.             /* Returns the location of the mouse in local coordinates. It does this by
  364.                calling OSEventAvail(). */ 
  365.  
  366. Point        GetGlobalTopLeft(WindowPtr window);
  367.             /*     Given a window, this will return the top left point of the window’s port in
  368.                   global coordinates. Something this doesn’t include, is the window’s drag
  369.                   region (or title bar). This returns the top left point of the window’s
  370.                   content area only. */
  371.  
  372. long        GetKFreeSpace(short vRefNum);
  373.  
  374. Rect        GetMainScreenRect(void);
  375.  
  376. GDHandle    GetRectDevice(Rect globalRect);
  377.             /* Find the greatest overlap device for the given global rectangle. */
  378.  
  379. Rect        GetRectDeviceRect(Rect globalRect);
  380.             /* Find the rect of the greatest overlap device for the given global rect. */
  381.  
  382. WindowPtr    GetSomeKindOfWindow(PositionWndProcPtr whatKind, short windID, Ptr storage, WindowPtr relWindow, WindowPtr behind, Boolean inColor);
  383.             /* Given a window positioning procedure pointer, a window ID and a window
  384.                pointer the window relates to, this function open a new window by either
  385.                a NewCWindow or a NewWindow call, depending on the value of inColor.  The
  386.                window will be opened invisible, independent of what the resource says.
  387.                Once the window is opened successfully, the positioning procedure is
  388.                called.  The positioning procedure is passed a pointer to the just-opened
  389.                invisible window and a pointer to the related window.  It is up to the
  390.                positioning procedure to move the invisible window to the correct location
  391.                on the correct device.  Once the positioning procedure returns, the window
  392.                will be made visible if so indicated by the resource. */
  393.  
  394. WindowPtr    GetStaggeredWindow(short id, Ptr storage, WindowPtr relWindow, WindowPtr behind, Boolean inColor);
  395.             /* Given a window ID and a window pointer the window relates to, this function
  396.                will stagger the window’s rectangle before showing it on the proper screen.
  397.                This follows the Apple Human Interface Guidelines for where to place a
  398.                staggered window on the screen.  If the window is not closely associated
  399.                with another window, pass a NULL for the window pointer of the related
  400.                window.  If you pass a NULL, the window is simply displayed where the
  401.                resource would indicate. */
  402.  
  403. TrapType    GetTrapType(short theTrap);
  404.             /* Returns the type (OSType or ToolType) of the trap. It does this by checking
  405.                the bits of the trap word. */ 
  406.  
  407. Rect        GetWindowContentRect(WindowPtr window);
  408.             /* Given a window pointer, return the global rectangle that encloses the
  409.                content area of the window. */
  410.  
  411. short        GetWindowCount(Boolean includeDAs, Boolean includeInvisibles);
  412.             /* This procedure counts the number of windows in the application plane.  You have the
  413.                choices of also including DAs and invisible windows in this count. */
  414.  
  415. GDHandle    GetWindowDevice(WindowPtr window);
  416.             /* Find the greatest overlap device for the given window. */
  417.  
  418. Rect        GetWindowDeviceRect(WindowPtr window);
  419.             /* Given a window pointer, find the device that contains most of the window
  420.                and return the device's bounding rectangle. */
  421.  
  422. Rect        GetWindowDeviceRectNMB(WindowPtr window);
  423.             /* Given a window pointer, find the device that contains most of the window
  424.                and return the device's bounding rectangle.  If this device is the main
  425.                device, then remove the menubar area from the rectangle. */
  426.  
  427. Rect        GetWindowStructureRect(WindowPtr window);
  428.             /* This procedure is used to get the rectangle that surrounds the entire
  429.                structure of a window.  This is true whether or not the window is visible.
  430.                If the window is visible, then it is a simple matter of using the bounding
  431.                rectangle of the structure region.  If the window is invisible, then the
  432.                strucRgn is not correct.  To make it correct, then window has to be moved
  433.                way off the screen and then made visible.  This generates a valid strucRgn,
  434.                although it is valid for the position that is way off the screen.  It still
  435.                needs to be offset back into the original position.  Once the bounding
  436.                rectangle for the strucRgn is obtained, the window can then be hidden again
  437.                and moved back to its correct location.  Note that ShowHide is used,
  438.                instead of ShowWindow and HideWindow.  HideWindow can change the plane of
  439.                the window.  Also, ShowHide does not affect the hiliting of windows. */
  440.   
  441. void        GlobalToLocalRect(Rect *aRect);
  442.  
  443. void        InitToolBox(void);
  444.  
  445. void        InitUtilities(void);
  446.             /* This sets up some global variables for use by the utilities package.  If you call
  447.                StandardInitialization, you don't need to call this, as it will do it for you. */ 
  448.  
  449. Boolean        IsAppWindow(WindowPtr window);
  450.             /* Returns TRUE if the windowKind of the window is greater than or equal to
  451.                userKind. If it is less, or the window is NIL, then return FALSE. */ 
  452.  
  453. Boolean        IsDAWindow(WindowPtr window);
  454.             /* Returns TRUE if the windowKind of the window is less than zero. If not, or
  455.                the window is NIL, then return FALSE. */ 
  456.  
  457. void        LocalToGlobalRect(Rect *aRect);
  458.  
  459. char        LockHandleHigh(Handle theHandle);
  460.             /* Does a MoveHHi on the handle and then locks it.  Also, the original state
  461.                of the handle is returned, so you can keep it and set the handle back to it's
  462.                original state with a HSetState call. */
  463.  
  464. short        NumToolboxTraps(void);
  465.             /* Determines the size of the Tool trap table. It does this by sampling a
  466.                couple of trap locations and seeing which, if any are Unimplemented. */ 
  467.  
  468. void        OutlineControl(ControlHandle button);
  469.  
  470. void         OutlineDialogItem(DialogPtr dlgPtr, short item);
  471.  
  472. void        PositionRectInRect(Rect outerRect, Rect *innerRect, Fixed horzRatio, Fixed vertRatio);
  473.             /* Given two rectangles, this routine positions the second within the first one
  474.                so that the it maintains the spacing specified the the horzRatio and vertRatio
  475.                parameters. In other words, to center an inner rectangle hoizontally, but
  476.                have its center be 1/3 from the top of the outer rectangle, call this
  477.                routine with horzRatio = FixRatio(1, 2), vertRatio = FixRatio(1, 3). */
  478.  
  479. void        PullApplicationToFront(void);
  480.             
  481. void        PStrConcat(Str255 targetStr, Str255 appendStr);
  482.             /* Concatenate a Pascal string onto another. */
  483.  
  484. void        SelectButton(ControlHandle button);
  485.             /* Given the button control handle, this will cause the button to look as if it
  486.                has been clicked in. This is nice to do for the user if they type return or
  487.                enter to select the default item. */
  488.  
  489. void        SetCheckOrRadioButton(DialogPtr dlgPtr, short itemNo, short state);
  490.  
  491. Rect        StaggerWindow(WindowPtr window, WindowPtr relatedWindow);
  492.             /* This algorithm for staggering windows does quite a good job.  It also is
  493.                quite gnarly.  Here's the deal:
  494.                There are pre-designated positions that we will try when positioning a
  495.                window.  These slots will be tried from the upper-left corner towards the
  496.                lower-right corner.  If there are other windows in that slot, then we will
  497.                consider that slot taken, and proceed to the next slot.  A slot is
  498.                determined to be taken by checking a point with a slop area.  This slop
  499.                area is diamond-shaped, not simply rectangular.  If there is no other
  500.                visible window with an upper-left corner within the slopt diamond, then
  501.                we are allowed to position our window there.
  502.                The above rule holds true unless this forces the window to be partly
  503.                off the screen.  If the window ends up partly off the screen, then we give
  504.                up and just put it in the first slot. */
  505.  
  506. void        StandardAbout(short appNameStringID);
  507.             /* Shows a standard about box with the name of the application, its version
  508.                number, a copyright notice, and DTS credits. Most of this information is
  509.                taking from a standard DITL and the application’s 'vers' resource. The name
  510.                of the application is taken either from the 'STR ' resource passed in to
  511.                this routine, or from GetAppParms() if that resource doesn’t exist, or you
  512.                pass in -1. */ 
  513.  
  514. void        StandardInitialization(short callsToMoreMasters);
  515.             /* Initializes “gInBackGround” to FALSE. Makes the following InitXXX calls:
  516.                InitGraf(), InitFonts(), InitWindows(), InitMenus(), TEInit(),
  517.                InitDialogs(), InitCursor(). Brings application to front with 3 EventAvail
  518.                calls. Calls SysEnvirons to initialize “gMac”. Calls TrapExists() to
  519.                initialize “gHasWaitNextEvent”. */ 
  520.    
  521. void        StandardMenuSetup(short MBARID, short AppleMenuID);
  522.             /* Installs and draws the menus indicated by 'MBAR'(MBARID). Adds DA’s to the
  523.                menu indicated by AppleMenuID by calling AddResMenu. If the menuBar cannot
  524.                be created, the alert specified by rDeathAlert is displayed. */   
  525.  
  526. void         ToggleCheck(DialogPtr dlgPtr, short cChkItem);
  527.  
  528. Boolean        TrapExists(short theTrap);
  529.             /* Returns TRUE if the trap exists (i.e., it’s callable without getting DS
  530.                error 12) */ 
  531.  
  532. void        ZoomToWindowDevice(WindowPtr window, short maxWidth, short maxHeight,
  533.                                short zoomDir, Boolean front);
  534.  
  535. #ifdef __cplusplus
  536. }
  537. #endif
  538.  
  539. #endif